﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SRF.Data
{
    /// <summary>
    /// 数据操作抽象类
    /// </summary>
    public abstract class DBHelperBase
    {
        /// <summary>
        /// 连接字符串
        /// </summary>
        public abstract string ConnectionString { get; }
        /// <summary>
        /// 数据库访问
        /// </summary>
        public abstract SRF.Data.Impl.Database Database { get; }
        /// <summary>
        /// 类和数据表映射信息
        /// </summary>
        public System.Collections.Generic.ICollection<Cfg.ClassInfo> ClassMappings { get; set; }
        /// <summary>
        /// 配置的sql
        /// </summary>
        public System.Collections.Generic.ICollection<Cfg.QueryInfo> Queries { get; set; }

        /// <summary>
        /// 获取IQuery对象
        /// </summary>
        /// <param name="sql">sql语句或sqlkey</param>
        /// <param name="mode">解析模式</param>
        /// <returns></returns>
        public abstract IQuery GetQuery(string sql, string mode = "");

        public abstract T Get<T>(object id) where T : class,new();
        public abstract int Insert(object entity);
        public abstract int Update(object entity, object id);
        public abstract int Delete<T>(object id);
        public abstract bool Exist<T>(object id);
    }
}